﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace filesIO {
    public class FileWrite {
        //static string _fileEncoding = "UTF-8";
        static UTF8Encoding utf8EmitBOM = new UTF8Encoding(false);

        static public void WriteFile(string path, string line) {
            //Encoding fileEncoding = Encoding.GetEncoding(_fileEncoding);

            if (!File.Exists(path)) {
                using (StreamWriter sw = File.CreateText(path)) {
                    sw.Close();
                }
            }

            File.AppendAllText(path, line+"\n", utf8EmitBOM);
        }
        
        static public void WriteFile(string path, List<string> lines) {
            
            if (!File.Exists(path)) {
                using (StreamWriter sw = File.CreateText(path)) {
                    sw.Close();
                }
            }
            foreach (string line in lines) 
                File.AppendAllText(path, line+"\n", utf8EmitBOM);
        }
    }
}
